<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<%
	String moduleId = request.getParameter("moduleId");
%>

<html>
	<head>
		<script type="text/javascript">
		
			$(function(){
		        loadGird("frm", 1);
			})
				
			var callback_frm = function(rows, frm) {
		       $.each(rows, function(i, n){
		    	   var row = $("#"+frm+" .template").clone().removeClass("template");
		   	       var keyValue = n.id;
			       row.find(".klId").attr("value",n.id);
			    	   	
					row.find(".klcode").text(n.code);
						   	
					row.find(".klname").text(n.name);
						   	
					row.find(".klmodule_describe").text(n.module_describe);
						   	
					row.find(".klurl").text(n.url);
						   	
					row.find(".kllink_type").text(n.link_type=="0"?"系统链接":"外部链接");
						   	
					row.find(".klismenu").text(n.ismenu=="1"?"是":"否");
			   	
		 		   row.attr("id","ready"+i);
		           row.attr("class","tr_nbw");
		           row.appendTo("#"+frm+" .grid");
		       });   
			}
			
			var delmodules = function(){
				var options = {
				type: 'POST',
				async: false,
				dataType: 'content-type',
				success: function(msg) {
					alertMsg("成功删除"+msg+"条记录");
					loadGird("frm", 1);
				}
				}
				if(confirm('您确认要删除吗？')){
					//提交form
					document.getElementById("frm").action="<%=path%>/sys/module/delmodules";
					$('#frm').ajaxSubmit(options);
				}
			}
			
			function addmodule(){
				opendailog("{src:'<%=path %>/sys/module/toEdit/0?pmoduleId=<%=moduleId %>',title:'模块属性',width:600,height:320,savefunc:'savefunc'}",window);
			}
			
			function modifymodule(){
				if(checkOnlySel()){
					opendailog("{src:'<%=path %>/sys/module/toEdit/"+getCheckedObj("chk")[0].value+"',title:'模块属性',width:600,height:320,savefunc:'savefunc'}",window);
				}
			}
			
			function savefunc(frame){
				var retv = frame.contentWindow.save()
				if(retv=="success"){
					alertMsg("保存成功！");
					reloadGrid("frm", 1);
				}
				return retv;
			}
		</script>
	</head>
<body>
	<form name="frm" method="post" style="margin: 0" action="<%=path %>/sys/module/list?moduleId=<%=moduleId %>" id="frm">
		<table width="100%">
			<tr>
				<td height="2px"></td>
			</tr>
			<tr><td align="right">
				<input type="button" onclick="addmodule();" class="button4_nbw" value="添加" />
				<input type="button" onclick="modifymodule();" class="button4_nbw" value="修改" />
				<input type="button" onclick="delmodules();" class="button4_nbw" value="删除" />
				&nbsp;&nbsp;
				</td>
			</tr>
		</table>
		<center>
		<table><tr><td height="2px"></td></tr></table>
		<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
			<thead class="th_nbw">
				<tr >
					<td width="40px" >
						<input type="checkbox" class="allCheck" />
					</td> 
		      		<td>
						编码
					</td>   
		      		<td>
						名称
					</td>  
		      		<td>
						描述
					</td>   
		      		<td>
						链接
					</td>   
		      		<td>
						链接类型
					</td>    
		      		<td>
						是否为系统菜单
					</td>  
				</tr>
			</thead>
			<tbody>
				<tr class="template klId">
					<td width="40px" class="idCheck">
						<input type="checkbox" name="chk" class="klId" />
					</td>
		   		    <td class="klcode niceTable-left"></td>
		   		    <td class="klname niceTable-left"></td>
		   		    <td class="klmodule_describe niceTable-left"></td>
		   		    <td class="klurl niceTable-left"></td>
		   		    <td class="kllink_type niceTable-left"></td>
		   		    <td class="klismenu niceTable-left"></td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td align="right" colspan="10" >
						<img class="loading"
							src="<%=imgPath %>/large-loading.gif" width="20px"
							class="hidden" />
						<span class="pagediv"></span>
					</td>
				</tr>
			</tfoot>
		</table>
		</center>
	</form>
</body>
</html>
